<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport" />
    <meta content="yes" name=" apple-mobile-web-app-capable" />
    <!-- 隐藏状态栏  -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <!-- <title>验证手机号码</title> -->
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/details.css">
</head>

<body>
    <header>
        <div class="wrapper clearfix">
            <div class="login_fl fl">
                <a href="javascript:history.back()" class="login_icon"><img src="img/srh_icon.png" alt=""></a>
            </div>
            <h1>验证手机号码</h1>
        </div>
    </header>
    <article class="mod-forgot p10 login_mod">
        <input type="text" class="phone" readonly="" value="" id="phoneNum">
        <a class="verify" href="javascript:void(0)" id="captchaBtn">发送验证码</a>
        <input type="text" class="vcode" placeholder="验证码" id="captcha">
        <input type="button" class="next_step" value="验证" onclick="submit()">
    </article>
</body>
<span style="display:none;"><script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1255764485'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s95.cnzz.com/z_stat.php%3Fid%3D1255764485%26show%3Dpic1' type='text/javascript'%3E%3C/script%3E"));</script></span>
<script src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="js/constants.js"></script>
<script src="js/common.js"></script>
<script>
var userInfo = getParameterByName('userInfo');
// 老的手机号
var oldphone = getParameterByName('phone');
$('#phoneNum').val(oldphone);

var regex = /^1[3|4|5|8|7][0-9]\d{4,8}$/;

var captchaBtn = $('#captchaBtn');

var remainTime = 60;

function captchaClick() {
    var urlCaptcha = server_host + '/userweb/update/sendSmsToUserResetPhoneNum.do?';

    if (regex.test(oldphone)) {
        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: urlCaptcha,
            success: function(data) {
                console.log(data.data);
                if (data.data.code == 0) {
                    captchaBtn.addClass('act');
                    captchaBtn.unbind('click');
                    captchaBtn.html(remainTime);
                    var timer = setInterval(function() {
                        remainTime--;
                        captchaBtn.html(remainTime);

                        if (remainTime == 0) {
                            clearInterval(timer);
                            captchaBtn.removeClass('act');
                            captchaBtn.bind('click', captchaClick);
                            captchaBtn.html('获取');
                            remainTime = 60;
                        }
                    }, 1000);
                } else {
                    alert(data.data.msg);
                }
            }
        });
    } else {
        alert('请输入正确的手机号码！');
    }
}

// 验证提交
function submit() {
    var urlSubmit = server_host + '/userweb/update/CheckResetPhoneNum.do?';
    var captcha = $('#captcha').val();
    if (captchaBtn == '') {
        alert('请输入验证码');
    } else {
        $.ajax({
            type: 'POST',
            dataType: 'json',
            url: urlSubmit + '&vNum=' + captcha,
            success: function(data) {
                console.log(data.data);
                if (data.data.isSuccess) {
                    alert(data.data.msg);
                    // alert(userInfo);
                    // console.log(userInfo);
                    location.href = 're_phonenum.html?userInfo=' + userInfo;
                } else {
                    alert(data.data.msg);
                }
            }
        });
    }
}


$(document).ready(function() {
    captchaBtn.bind('click', captchaClick);
});
</script>
<script>
    _maq.push(['_setMaq', 're-phoneNum-verrify']);
</script>
</html>
